package com.jyh;

import com.jyh.entity.Dog;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.util.concurrent.TimeUnit;

@SpringBootTest
class SpringbootRedisApplicationTests2 {

    @Autowired
    private RedisTemplate redisTemplate;
    @Test
    void contextLoads() {
//        redisTemplate.setKeySerializer(new StringRedisSerializer());
//        redisTemplate.setValueSerializer(new  GenericJackson2JsonRedisSerializer());

        ValueOperations forValue = redisTemplate.opsForValue();
        forValue.set("k10",new Dog(2,"旺财"));

        Object k10 = forValue.get("k10");
        System.out.println("k10的值是："+k10);
    }


}
